package stu.sup.service.impl;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stu.sup.entity.ProductComment;
import stu.sup.mapper.ProductCommentMapper;
import stu.sup.service.ICommentServce;
import stu.sup.service.ICouponService;

import java.util.List;

/**
 * Created by HUAWEI on 2020/6/26.
 */
@Service
@Transactional
public class CommentServiceImpl implements ICommentServce{
    private ProductCommentMapper productCommentMapper;
    @Override
    public List<ProductComment> findComment(int productId) {
        List<ProductComment> productComments;
        productComments=productCommentMapper.selectbyproductId(productId);
        return productComments;
    }

    @Override
    public List<ProductComment> findbyType(String commentType) {
        List<ProductComment> productComments;
        productComments=productCommentMapper.selectbyType(commentType);
        return productComments;
    }

    @Override
    public boolean addComment(ProductComment productComment) {
        int count=productCommentMapper.insert(productComment);
        return count==0?false:true;
    }

    @Override
    public boolean delateComment(int commentId) {
        int count=productCommentMapper.deleteByPrimaryKey(commentId);
        return count==0?false:true;
    }
}
